﻿//// --------------------------------------------------------------------------------------------------------------------
//// <copyright file="CreateSiteTest.cs" company="Collaboris Ltd.">
////   Copyright (c) Collaboris Ltd. All rights Reserved.
//// </copyright>
//// <summary>
////   
//// </summary>
//// --------------------------------------------------------------------------------------------------------------------
//// ********************************************************************************
//// The Tests in this Unit Test will test the "CreateSite" Action only.
//// To run any of these unit tests, you must do the following : 
////   - Create a Web App (Port 80, host hdr 'local.collaboris.co.uk'    
////   - Create a site collection ('http://local.collaboris.co.uk/sites/team')
////     (the Template should be a "Team Site")
////   - The user that you run VS under must be a site collecion adminstrator
//// ********************************************************************************
//namespace Collaboris.Saf.Actions.Wss.Tests.WebPart
//{
//    using System;
//    using System.Collections.Generic;
//    using System.IO;
//    using System.Web.UI.WebControls.WebParts;

//    using Engine;
//    using Engine.Report;

//    using Entities;

//    using Microsoft.SharePoint;
//    using Microsoft.SharePoint.WebPartPages;
//    using Microsoft.VisualStudio.TestTools.UnitTesting;

//    using Saf.Tests;

//    using SharePoint.Wss.Files;
//    using SharePoint.Wss.Lists;
//    using SharePoint.Wss.WebParts;

//    using Utils;

//    using Wss.WebPart;

//    using TestGlobals=Collaboris.Saf.Actions.Wss.Tests.TestGlobals;
//    using TestHelper=Collaboris.Saf.Actions.Wss.Tests.TestHelper;
//    using WebPart=Microsoft.SharePoint.WebPartPages.WebPart;

//    /// <summary>
//    /// Tests the EnsureListRowsTest Action
//    /// </summary>
//    [TestClass]
//    public class ConnectWebPartsTest
//    {

//        #region Common Test specific changes

//        /*
//        /// <summary>
//        /// Gets the macro file relative.
//        /// </summary>
//        /// <returns></returns>
//        public override string GetMacroFileRelative()
//        {
//            return @"WSS.ContentType.AddToList\macro.xml";
//        }
//        */

//        /// <summary>
//        /// Runs Before all tests.
//        /// </summary>
//        /// <param name="testContext">The test context.</param>
//        [ClassInitialize()]
//        public static void BeforeAllTests(TestContext testContext)
//        {
//            //TestHelper.CreateTeamSite(TestGlobals.WSSSite, "EnsureContentType", "webContentTypes");
//            //using (SPSite site = new SPSite(TestGlobals.WSSSite))
//            //{
//            //    using (SPWeb newWeb = SPWebHelper.GetWeb(site, "webContentTypes"))
//            //    {
//            //        TestHelper.CreatePersonListWithContentType(newWeb, true, true);

//            //    }
//            //}
//        }

//        /// <summary>
//        /// Runs After all Tests.
//        /// </summary>
//        [ClassCleanup()]
//        public static void AfterAllTests()
//        {

//        }

//        /// <summary>
//        /// Befores the each test.
//        /// </summary>
//        [TestInitialize()]
//        public void BeforeEachTest() { }

//        /// <summary>
//        /// Use TestCleanup to run code after each test has run.
//        /// </summary>
//        [TestCleanup()]
//        public void AfterEachTest() { }

//        #endregion

//        #region Test Methods / Cases

//        [TestMethod]
//        public void Test_Web_Part_Connections()
//        { 
//            const string MacroPath = TestGlobals.ProjectTestDirectory + @"\Connect_Web_Part_Test.xml";
//            SafContext safContext;
 
//            using (SPSite site = new SPSite(TestGlobals.WSSSite))
//            {  
//                // DO  
//                using (SPWeb newWeb = site.RootWeb)
//                { 
//                    TestHelper.DoMacro(MacroPath, TestGlobals.WSSSite, out safContext);
//                }   

//                // UNDO
//                using (SPWeb newWeb = site.RootWeb)
//                {
//                    TestHelper.UndoMacro(MacroPath, TestGlobals.WSSSite, safContext);
//                }
//            }
//        }

//        [TestMethod]
//        public void Test_Remove_Web_Parts()
//        {
//            WSSTestAssistant<RemoveWebParts, WebPartListInfo> removeWebParts = 
//                new WSSTestAssistant<RemoveWebParts, WebPartListInfo>(TestEnvironment.PublishingSite, "RemoveWebPartsTestWeb", "BLANKINTERNET#0");

//            using (removeWebParts)
//            {
//                Guid listGuid = SPListHelper.GetListGuid(removeWebParts.TestWeb, "Pages");

//                ListViewWebPart listViewWebPart = new  ListViewWebPart();
//                listViewWebPart.ListName = listGuid.ToString("B").ToUpper(); 
//                listViewWebPart.ID = "MyListViewWebPart";
//                listViewWebPart.Title = "MyListViewWebPart Title";

//                SPFileHelper.CheckOutFile(removeWebParts.TestWeb.Url + @"/Pages/default.aspx");

//                List<WebPart> webParts = new List<WebPart>() {listViewWebPart};
//                SPWebPartHelper.AddWebParts(removeWebParts.TestWeb, "pages", "default.aspx", webParts, "TopZone", true, PersonalizationScope.Shared);
//                MacroReport report = removeWebParts.DoMacro();

//                SPWebPartHelper.GetWebPartFromPage(
//                    removeWebParts.TestWeb, @"/Pages/default.aspx", "listViewWebPart.ID", PersonalizationScope.Shared);
//                // Asserts to go here
//            }
           
//        }

//        #endregion
//    }
//}